Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Net.Mail
Public Class clsMails
    Public Function objEnviarMail(ByVal MailOrigen As String, ByVal MailDestino As String, ByVal MailAsunto As String, _
                    ByVal MailCuerpo As String, ByVal MailUser As String, ByVal MailPassword As String)

        Dim Mail As New System.Net.Mail.MailMessage
        Dim Servidor As New System.Net.Mail.SmtpClient
        Mail.From = New System.Net.Mail.MailAddress(MailOrigen)
        Mail.To.Add(MailDestino)
        Mail.Subject = MailAsunto
        Mail.Body = MailCuerpo
        Mail.IsBodyHtml = False
        Mail.Priority = MailPriority.Normal
        Servidor.Host = TramiteDocumentario.gcMailServer
        Servidor.Credentials = New System.Net.NetworkCredential(TramiteDocumentario.gcMailName, TramiteDocumentario.gcMailPassword)

        Try
            Servidor.Send(Mail)
        Catch ex As Exception
            'Throw ex
        End Try

        Return 1
    End Function
    Public Function objMosPerMails(ByVal PerCodigo As String, _
                                ByVal MyTrans As SqlTransaction, _
                                ByVal Cn As SqlConnection) As SqlDataReader

        Dim Sql As String = "Select cPerMaiNombre AS Mail From PerMail Where cPerCodigo= '" & PerCodigo & "' " & _
                            "AND Right(cPerMaiNombre,11)= '@uss.edu.pe'"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(Sql, MyTrans, Cn)
    End Function
    Public Function objMosUniOrgMails(ByVal UOCodigo As Integer, ByVal UOTipo As Integer, _
                                ByVal MyTrans As SqlTransaction, _
                                ByVal Cn As SqlConnection) As SqlDataReader

        Dim Sql As String = "Select cUniOrgMailNombre AS Mail From UniOrgMail " & _
                            "Where nUniOrgCodigo = " & UOCodigo & " AND nUniOrgMailTipo = " & UOTipo & ""

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(Sql, MyTrans, Cn)
    End Function
End Class
